home *** CD-ROM | disk | FTP | other *** search
/ DarkBASIC - The Ultimate 3D Game Creator / PCactive 8 CD1 - DarkBasic.iso / SOFTWARE / DEMOS / DarkForge2000 / 2d_parallax_starfield / 2d_parallax_starfield.DBA next >
Encoding:
Text File  |  2000-04-12  |  921 b   |  52 lines

  1. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  2. `          2D Parallax Starfield
  3. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  4. ` By Rich Davey (rich@fatal-design.com)
  5. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  6. ` Music listened  to while  coding this
  7. ` Madonna (Ray of Light)
  8. ` -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
  9. ` Note:
  10. `
  11. ` On my graphics card (GeForce 256 Pro) I can get a consistent 75 fps
  12. ` with 500 stars on-screen. You can push this up to around 800 stars
  13. ` if you change the x array into 3 seperate arrays, instead of having
  14. ` 1 array with 3 elements.
  15.  
  16. sync rate 0
  17. sync on
  18. hide mouse
  19.  
  20. n=500
  21. dim x(n,3)
  22.  
  23. for i=1 to n
  24.     x(i,1)=rnd(639)+1
  25.     x(i,2)=rnd(479)+ 1
  26.     x(i,3)=rnd(9)+1
  27. next i
  28.  
  29. do
  30.     cls 0
  31.  
  32.     for i=1 to n
  33.  
  34.         x(i,1)=x(i,1)-x(i,3)
  35.         
  36.         if x(i,1)<=1
  37.             x(i,1)=640
  38.             x(i,2)=rnd(479)+1
  39.         endif
  40.     
  41.         col=x(i,3)*30
  42.         ink rgb(col,col,col),1
  43.  
  44.         dot x(i,1),x(i,2)
  45.     
  46.     next i
  47.  
  48.     sync
  49.  
  50. loop
  51.  
  52.